package com.primaryedu.ui.app.classadjust;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.primaryedu.R;
import com.primaryedu.ui.BaseActivity;

/**
 * Created by Thomas on 2018/3/6.
 */

public class ClassDetailsActivtiy extends BaseActivity implements View.OnClickListener {

    private RadioGroup radioGroup;
    private int approveId;
    private RadioButton rb_disagree_details;
    private RadioButton rb_agree_details;
    private static final int REQUEST_PREVIEW_CODE = 20;
    private TextView tv_auditorName;
    private TextView text_remark;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_class_details);

        init();
    }

    private void init() {
        Intent intent = getIntent();
        //调课信息
        String remarks = intent.getStringExtra("remarks");
        //课务ID
        String id = intent.getStringExtra("id");
        //处理状态
        String leaveStaus = intent.getStringExtra("staus");
        Log.i("yy", "init: leaveStaus=====" + leaveStaus);
        //审批人auditorname
        String auditorname = intent.getStringExtra("auditorname");
        ((TextView) findViewById(R.id.title)).setText("调课审批");
        findViewById(R.id.back).setOnClickListener(this);

        radioGroup = (RadioGroup) findViewById(R.id.radioGroup_details);
        rb_agree_details = (RadioButton) findViewById(R.id.rb_agree_details);
        rb_disagree_details = (RadioButton) findViewById(R.id.rb_disagree_details);
        disableRadioGroup(radioGroup);
        ImageView image_class_details = (ImageView) findViewById(R.id.image_class_details);
        if (leaveStaus.equals("2")) {//同意
            image_class_details.setBackgroundResource(R.drawable.image_agree);
            rb_agree_details.setChecked(true);
        } else if (leaveStaus.equals("1")) {//未处理
//            image_class_details.setBackground(this.getResources().getDrawable(R.drawable.leave_no_deal));
            image_class_details.setBackgroundResource(R.drawable.leave_no_deal);
        } else if (leaveStaus.equals("3")) {//请假不同意
            image_class_details.setBackgroundResource(R.drawable.image_disagree);
            rb_disagree_details.setChecked(true);
        }
        //调课信息
        text_remark = (TextView) findViewById(R.id.text_remark);
        text_remark.setText(remarks);
        //审批人
        tv_auditorName = (TextView) findViewById(R.id.tv_auditorName);
        tv_auditorName.setText(auditorname);
        //审批意见
        radioGroup = (RadioGroup) findViewById(R.id.radioGroup_details);
        disableRadioGroup(radioGroup);
        rb_agree_details = (RadioButton) findViewById(R.id.rb_agree_details);
        rb_disagree_details = (RadioButton) findViewById(R.id.rb_disagree_details);
//        rb_agree_details.setChecked(false);
//        rb_disagree_details.setChecked(false);

    }

    @Override
    protected int BindLayout() {
        return R.layout.activity_class_details;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    public void disableRadioGroup(RadioGroup testRadioGroup) {
        for (int i = 0; i < testRadioGroup.getChildCount(); i++) {
            testRadioGroup.getChildAt(i).setEnabled(false);
        }
    }

    public void enableRadioGroup(RadioGroup testRadioGroup) {
        for (int i = 0; i < testRadioGroup.getChildCount(); i++) {
            testRadioGroup.getChildAt(i).setEnabled(true);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back:
                finish();
                break;
        }
    }
}
